package com.lucy.property.entity;

import com.lucy.common.core.BaseEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.checkerframework.checker.units.qual.C;
import org.hibernate.Hibernate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Objects;

/**
 * @author kindeAR
 * 物业单元
 */
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
@Table(name = "property_unit")
@ApiModel(value = "物业服务单元")
public class PropertyUnit extends BaseEntity implements Serializable {

    @ApiModelProperty("单元编码")
    @Column(name = "unit_code")
    String unitCode;

    @ApiModelProperty("单元名称")
    @Column(name = "unit_name")
    String unitName;

    @ApiModelProperty("单元地址")
    @Column(name = "location")
    String location;

    @ApiModelProperty("单元备注")
    @Column(name = "remark")
    String remark;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
            return false;
        }
        PropertyUnit that = (PropertyUnit) o;
        return getId() != null && Objects.equals(getId(), that.getId());
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }
}
